import javax.swing.*;

public class StudentPanel extends JFrame {
    public StudentPanel(Student student) {
        setTitle("学生面板");
        setSize(400, 300);
        setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

        JPanel panel = new JPanel();
        add(panel);
        placeComponents(panel, student);
    }

    private void placeComponents(JPanel panel, Student student) {
        panel.setLayout(null);

        JLabel infoLabel = new JLabel("学生信息");
        infoLabel.setBounds(10, 20, 80, 25);
        panel.add(infoLabel);

        JLabel idLabel = new JLabel("学号: " + student.getId());
        idLabel.setBounds(10, 50, 300, 25);
        panel.add(idLabel);

        JLabel nameLabel = new JLabel("姓名: " + student.getName());
        nameLabel.setBounds(10, 80, 300, 25);
        panel.add(nameLabel);

        JLabel classLabel = new JLabel("班级: " + student.getClassName());
        classLabel.setBounds(10, 110, 300, 25);
        panel.add(classLabel);

        JLabel ageLabel = new JLabel("年龄: " + student.getAge());
        ageLabel.setBounds(10, 140, 300, 25);
        panel.add(ageLabel);

        JLabel heightLabel = new JLabel("身高: " + student.getHeight());
        heightLabel.setBounds(10, 170, 300, 25);
        panel.add(heightLabel);
    }
}
